package com.peak.distribution.entity.goods;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;

import com.peak.distribution.enums.Constants;
import com.peak.spring.boot.api.entity.DefaultStategyEntity;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 商品阶梯价格
 * 
 * @author Haley Gao
 *
 */
@Entity
@Table(name = "dis_goods_price_rule")
@Data
@EqualsAndHashCode(callSuper = true)
public class DisGoodsPriceRule extends DefaultStategyEntity {

	private static final long serialVersionUID = Constants.DISTRIBUTION_VERSION;

	/** 区间内价格 */
	private Integer price;

	/** 最小数量 */
	private Integer minQuantity;

	/** 最大数量 */
	private Integer maxQuantity;

	/** 商品 */
	private DisGoods goods;

	@ManyToOne
	@JoinColumn(name = "goods_id")
	@Fetch(FetchMode.SELECT)
	@LazyToOne(LazyToOneOption.PROXY)
	public DisGoods getGoods() {
		return goods;
	}
}
